//
//  SISSAutoSizeImageShowViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2017/10/23.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSAutoSizeImageShowViewController.h"
#import "SISSBaseTableView.h"

static NSString *autoSizeImageShowCellReuseID = @"autoSizeImageShowCellReuseID";
@interface SISSAutoSizeImageShowViewController ()<UITableViewDelegate,UITableViewDataSource>

// tableView
@property (weak, nonatomic) SISSBaseTableView *tableView;




@end

@implementation SISSAutoSizeImageShowViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
}

#pragma mark - UITableViewDelegate & UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.imageArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:autoSizeImageShowCellReuseID forIndexPath:indexPath];
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = self.imageArr[indexPath.row];
    [cell.contentView addSubview:imageView];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(cell.contentView);
        make.bottom.right.equalTo(cell.contentView);
    }];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    
    SISSBaseTableView *tableView = [[SISSBaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    
    tableView.dataSource = self;
    tableView.delegate = self;
    // 自动行高
    tableView.estimatedRowHeight = 80;
    tableView.rowHeight = UITableViewAutomaticDimension;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:autoSizeImageShowCellReuseID];
    
    [self.view addSubview:tableView];
    self.tableView = tableView;
    
    WeakSelf
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_topLayoutGuideBottom);
        make.left.right.bottom.equalTo(weakSelf.view);
    }];
}


@end
